﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using com.clinica.business.BE.actcliente;
using com.clinica.business.BE.comun;
using com.clinica.business.BL.interfaces.actcliente;
using com.clinica.business.BL.interfaces.gesliq;
using com.clinica.config;

namespace LiclCliente
{
    public class LiclClienteController
    {
        BeginConfig config = new BeginConfig();
        public LiclClienteController()
        { 
        
        }
        public List<ParametrosBE> Obtener_Tabla(ParametrosBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oParm = factory.CreateChannel();
                List<ParametrosBE> lst = oParm.ObternerTipoDocumento (oRequest);
                factory.Close();
                return lst;
            }
        }
        public List<ClienteBE> Obtener_Clientes(ClienteBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oClie = factory.CreateChannel();
                List<ClienteBE> lst = oClie.ObtenerClientes(oRequest);
                factory.Close();
                return lst;
            }
        }
        public List<ClienteBE> Obtener_ClientesPopup(ClienteBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oClie = factory.CreateChannel();
                List<ClienteBE> lst = oClie.ObtenerClientesPopup(oRequest);
                factory.Close();
                return lst;
            }
        }

        public List<ParametrosBE> Obtener_TablaTipoCliente(ParametrosBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oParm = factory.CreateChannel();
                List<ParametrosBE> lst = oParm.ObternerTipoCliente(oRequest);
                factory.Close();
                return lst;
            }
        }
        public List<ParametrosBE> Obtener_TablaTipoDocIdent(ParametrosBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oParm = factory.CreateChannel();
                List<ParametrosBE> lst = oParm.ObternerTipoDocIdent(oRequest);
                factory.Close();
                return lst;
            }
        }
        public List<ParametrosBE> Obtener_TablaDistrito(ParametrosBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oParm = factory.CreateChannel();
                List<ParametrosBE> lst = oParm.ObternerDistrito(oRequest);
                factory.Close();
                return lst;
            }
        }        
      
        //public List<DocumentoPagoBE> Obtener_DocumentosPago(DocumentoPagoBE oRequest)
        //{
        //    ChannelFactory<IDocumentoPagoBL> factory = null;
        //    using (factory = new ChannelFactory<IDocumentoPagoBL>(config.Context + "DocumentoPago"))
        //    {
        //        IDocumentoPagoBL oPacie = factory.CreateChannel();
        //        List<DocumentoPagoBE> lst = oPacie.ObtenerDocumentoPago(oRequest);
        //        factory.Close();
        //        return lst;
        //    }
        //}
        //public List<com.clinica.business.BE.gesliq.PacienteBE> Buscar_Paciente_Detalle(com.clinica.business.BE.gesliq.PacienteBE oRequest)
        //{
        //    ChannelFactory<IPacienteBL> factory = null;
        //    using (factory = new ChannelFactory<IPacienteBL>(config.Context + "Paciente"))
        //    {
        //        IPacienteBL oPacie = factory.CreateChannel();
        //        List<com.clinica.business.BE.gesliq.PacienteBE> lst = oPacie.BuscarPacienteDetalle(oRequest);
        //        factory.Close();
        //        return lst;
        //    }
        //}
        //public List<DocumentoPagoBE> Obtener_Consumos(DocumentoPagoBE oRequest)
        //{
        //    ChannelFactory<IDocumentoPagoBL> factory = null;
        //    using (factory = new ChannelFactory<IDocumentoPagoBL>(config.Context + "DocumentoPago"))
        //    {
        //        IDocumentoPagoBL oPacie = factory.CreateChannel();
        //        List<DocumentoPagoBE> lst = oPacie.ObternerConsumos(oRequest);
        //        factory.Close();
        //        return lst;
        //    }
        //}

        public List<ClienteBE> Obtener_Cliente(ClienteBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oClie = factory.CreateChannel();
                List<ClienteBE> lst = oClie.ObtenerCliente(oRequest);
                factory.Close();
                return lst;
            }
        }
        public int Grabar_Cliente(int Accion, ClienteBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oPacie = factory.CreateChannel();
                int result = oPacie.ActualizarCliente(Accion, oRequest);
                factory.Close();
                return result;
            }
        }
        public void Eliminar_Cliente(ClienteBE oRequest)
        {
            ChannelFactory<IClienteBL> factory = null;
            using (factory = new ChannelFactory<IClienteBL>(config.Context + "Cliente"))
            {
                IClienteBL oCli = factory.CreateChannel();
                oCli.EliminarCliente(oRequest);
                factory.Close();
            }
        }
    }
}
